﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entidad;
using Negocio.BL;

namespace EvolSoftWeb
{
    public partial class wfrmFactura : System.Web.UI.Page
    {
        FacturaLogic blFactura = new FacturaLogic();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void insertarFactura()
        {
            try
            {
                SRH_FACTURA obj = new SRH_FACTURA();
                obj.estado = 1;
                obj.fecha = dtefecha.Date;
                obj.idFactura =blFactura.ObtenerNroFactura();
                obj.idReserva = Convert.ToInt32(txtidreserva.Text);
                obj.IGV = Convert.ToInt32(txtigv.Text);
                obj.montoBruto = Convert.ToDecimal(txtmontobruto.Text);
                obj.montoTotal =Convert.ToDecimal(txtmontototal.Text);
                obj.numero = txtnumero.Text;
             if (blFactura.Insertar(obj))
	{
                 lblmsgOK.Text="Se registro correctamente la factura";
                 popupOK.ShowOnPageLoad=true;
	}


            }
            catch (Exception ex)
            {
                lblmsgOK.Text=ex.InnerException==null?ex.Message:ex.InnerException.Message;
                 popupOK.ShowOnPageLoad=true;
            }
        }

        protected void btngrabar_Click(object sender, EventArgs e)
        {
            this.insertarFactura();
        }

        protected void ASPxButton3_Click(object sender, EventArgs e)
        {
            Response.Redirect("wFrmDefault.aspx?id=8");
        }
    }
}